# 导包
from selenium import webdriver
from selenium.webdriver.common.by import By
# 导入键盘操作类
from selenium.webdriver.common.keys import Keys
# 导入鼠标操作类
from selenium.webdriver.common.action_chains import ActionChains
from time import sleep
# 获取浏览器驱动
driver = webdriver.Firefox()
# 打开测试页面
url = 'file:///C:/Users/tedu/Desktop/NSD2406/html/registerA.html'
driver.get(url)
# 实例化鼠标操作对象
action = ActionChains(driver)
# 输入用户名，退格一次
username = driver.find_element(By.CSS_SELECTOR, '#userA')
username.send_keys('admin8')
sleep(3)
username.send_keys(Keys.BACKSPACE)
# ctrl+z
sleep(3)
username.send_keys(Keys.CONTROL, 'z')
#全选，复制，在密码框的输入框粘贴
sleep(3)
# 执行双击完成全选
action.double_click(username).perform()
# 执行复制操作
username.send_keys(Keys.CONTROL, 'c')
sleep(3)
password = driver.find_element(By.CSS_SELECTOR, '#passwordA')
# 在密码框输入框粘贴
password.send_keys(Keys.CONTROL, 'v')

# 关闭浏览器驱动
sleep(3)
driver.quit()